﻿using Microsoft.Extensions.Hosting;
using System.Diagnostics;

namespace ConsoleTest.Services
{
    internal class HttpClientService : IHostedService
    {
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            HttpClient httpClient = new();
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "http://127.0.0.1:8500/v1/health/service/RCAuthority");
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            HttpResponseMessage response = await httpClient.SendAsync(message);
            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);
        }

        public async Task StopAsync(CancellationToken cancellationToken) => await Task.CompletedTask;
    }
}
